]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
viewSelector: allow programmatically switching to tabs
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 9 Mar 2011 00:26:28 +0000 (19:26 -0500)
committerOwen W. Taylor <otaylor@fishsoup.net>
Sat, 12 Mar 2011 00:25:40 +0000 (19:25 -0500)
Add the idea of an 'id' for a tab, and add a public switchTab method
so you can switch to 'applications' or 'windows'. This will be useful
for performance tests that test tab switching performance.

https://bugzilla.gnome.org/show_bug.cgi?id=644266

js/ui/overview.js
js/ui/viewSelector.js

index 2d672868fd878ec9b935fead2acf426a56eb60ff..b6c30d9bc4b8b4fc294e93dc82ca25173f1c1cc9 100644 (file)
@@ -180,10 +180,10 @@ Overview.prototype = {
         this._group.add_actor(this.viewSelector.actor);
 
         this._workspacesDisplay = new WorkspacesView.WorkspacesDisplay();
-        this.viewSelector.addViewTab(_("Windows"), this._workspacesDisplay.actor, 'text-x-generic');
+        this.viewSelector.addViewTab('windows', _("Windows"), this._workspacesDisplay.actor, 'text-x-generic');
 
         let appView = new AppDisplay.AllAppDisplay();
-        this.viewSelector.addViewTab(_("Applications"), appView.actor, 'system-run');
+        this.viewSelector.addViewTab('applications', _("Applications"), appView.actor, 'system-run');
 
         // Default search providers
         this.viewSelector.addSearchProvider(new AppDisplay.AppSearchProvider());
index 5cad9cd529a12189b58d46fa6b2f15d831ca3f36..6cb05961b703e1b2f964aa4ea4642cedcd603954 100644 (file)
@@ -77,14 +77,16 @@ BaseTab.prototype = {
 Signals.addSignalMethods(BaseTab.prototype);
 
 
-function ViewTab(label, pageActor, a11yIcon) {
-    this._init(label, pageActor, a11yIcon);
+function ViewTab(id, label, pageActor, a11yIcon) {
+    this._init(id, label, pageActor, a11yIcon);
 }
 
 ViewTab.prototype = {
     __proto__: BaseTab.prototype,
 
-    _init: function(label, pageActor, a11yIcon) {
+    _init: function(id, label, pageActor, a11yIcon) {
+        this.id = id;
+
         let titleActor = new St.Button({ label: label,
                                          style_class: 'view-tab-title' });
         titleActor.connect('clicked', Lang.bind(this, this._activate));
@@ -383,8 +385,8 @@ ViewSelector.prototype = {
         }));
     },
 
-    addViewTab: function(title, pageActor, a11yIcon) {
-        let viewTab = new ViewTab(title, pageActor, a11yIcon);
+    addViewTab: function(id, title, pageActor, a11yIcon) {
+        let viewTab = new ViewTab(id, title, pageActor, a11yIcon);
         this._tabs.push(viewTab);
         this._tabBox.add(viewTab.title);
         this._addTab(viewTab);
@@ -433,6 +435,14 @@ ViewSelector.prototype = {
         }
     },
 
+    switchTab: function(id) {
+        for (let i = 0; i < this._tabs.length; i++)
+            if (this._tabs[i].id == id) {
+                this._switchTab(this._tabs[i]);
+                break;
+            }
+    },
+
     _switchDefaultTab: function() {
         if (this._tabs.length > 0)
             this._switchTab(this._tabs[0]);